package com.fqyd.campustransaction.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.fqyd.campustransaction.mapper.OrderDetailsMapper;
import com.fqyd.campustransaction.model.OrderDetails;
import com.fqyd.campustransaction.model.OrderDetailsExample;
import com.fqyd.campustransaction.service.OrderDetailsService;

/**
 * 购物车
 */
@Service
public class OrderDetailsServiceImpl implements OrderDetailsService {

	@Resource
	private OrderDetailsMapper mapper;

	@Override
	public List<OrderDetails> getAll() {
		return mapper.selectByExample(new OrderDetailsExample());
	}

	@Override
	public void add(OrderDetails orderDetails) {
		mapper.insert(orderDetails);
	}

	@Override
	public void update(OrderDetails orderDetails) {
		mapper.updateByPrimaryKey(orderDetails);
	}

	@Override
	public void delete(String id) {
		mapper.deleteByPrimaryKey(id);
	}

	@Override
	public OrderDetails getById(String id) {
		return mapper.selectByPrimaryKey(id);
	}

	@Override
	public List<OrderDetails> getByOrderId(String orderId) {
		OrderDetailsExample example = new OrderDetailsExample();
		OrderDetailsExample.Criteria criteria = example.createCriteria();
		criteria.andOrderIdEqualTo(orderId);
		return mapper.selectByExample(example);
	}
}
